package com.baizhi.cmfz.service.impl;

import com.baizhi.cmfz.dao.AudioDao;
import com.baizhi.cmfz.entity.Audio;
import com.baizhi.cmfz.service.AudioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class AudioServiceImpl implements AudioService {

    @Autowired
    private AudioDao audioDao;

    @Override
    public Map showPageAudio(int page, int limit, String aName) {
        if(aName==null){
            aName=null;
        }else {
            aName="%"+aName+"%";
        }
        int offset=(page-1)*limit;
        List<Audio> list=audioDao.showPageAudio(offset,limit,aName);
        int count=audioDao.showCount(aName);
        Map map=new HashMap();
        map.put("data",list);
        map.put("count",count);
        map.put("code",0);
        map.put("msg","");
        return map;
    }
}
